package com.xjrsoft.module.customerTwo.aiplm.t_aiplm_text2img.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaMode;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xjrsoft.common.page.PageOutput;
import com.xjrsoft.common.page.ConventPage;
import java.util.List;
import com.xjrsoft.common.utils.DataTransUtil;
import com.xjrsoft.common.result.Response;
import com.xjrsoft.core.tool.utils.BeanUtil;
import com.xjrsoft.module.customerTwo.aiplm.t_aiplm_text2img.dto.TAiplmText2imgDto;
import com.xjrsoft.module.customerTwo.aiplm.t_aiplm_text2img.dto.SaveTAiplmText2imgFormDataDto;
import com.xjrsoft.module.customerTwo.aiplm.t_aiplm_text2img.vo.TAiplmText2imgVo;
import com.xjrsoft.module.customerTwo.aiplm.t_aiplm_text2img.vo.TAiplmText2imgListVo;
import com.xjrsoft.module.customerTwo.aiplm.t_aiplm_text2img.dto.TAiplmText2imgListDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;

import org.springframework.web.bind.annotation.*;
import com.xjrsoft.module.customerTwo.aiplm.t_aiplm_text2img.entity.TAiplmText2img;
import com.xjrsoft.module.customerTwo.aiplm.t_aiplm_text2img.vo.TAiplmText2imgVo;
import com.xjrsoft.module.customerTwo.aiplm.t_aiplm_text2img.service.ITAiplmText2imgService;

/**
 *  控制器
 *
 * @author dongxinhang
 * @since 2024-07-04
 */
@RestController
@AllArgsConstructor
@RequestMapping("/t_aiplm_text2img")
@Api(value = "智能微设计模式", tags = "智能微设计模式接口")
public class TAiplmText2imgController {


	private final ITAiplmText2imgService tAiplmText2imgService;


	/**
	 * 详情 
	 */
	@GetMapping("/{id}")
	@ApiOperation(value = "详情", notes = "传入tAiplmText2img")
	@SaCheckPermission(value = {"t_aiplm_text2img:view", "t_aiplm_text2img:modify"}, mode = SaMode.OR)
	public Response<TAiplmText2imgVo> getFormData(@PathVariable String id) {
		// 主表数据
		TAiplmText2img tAiplmText2img = tAiplmText2imgService.getById(id);
		TAiplmText2imgVo tAiplmText2imgVo = BeanUtil.copy(tAiplmText2img, TAiplmText2imgVo.class);
		return Response.ok(tAiplmText2imgVo);
	}

	/**
	 * 自定义分页 
	 */
	@GetMapping
	@ApiOperation(value = "分页", notes = "传入tAiplmText2img")
		public Response<PageOutput<TAiplmText2imgListVo>> getPageList(TAiplmText2imgListDto listDto) {
		IPage<TAiplmText2img> page = tAiplmText2imgService.getPageList(listDto);
		List<TAiplmText2imgListVo> records = BeanUtil.copyList(page.getRecords(), TAiplmText2imgListVo.class);
			// 转换列表数据
		DataTransUtil.transListShowData(records);
		return Response.ok(ConventPage.getPageOutput(page.getTotal(), records));
	}

	/**
	 * 新增 
	 */
	@PostMapping
	@ApiOperation(value = "新增", notes = "传入tAiplmText2img")
	@SaCheckPermission("t_aiplm_text2img:add")
	public Response save(@RequestBody SaveTAiplmText2imgFormDataDto formDto) {
		TAiplmText2imgDto tAiplmText2imgDto = formDto.getTAiplmText2imgDto();
		TAiplmText2img tAiplmText2img = BeanUtil.copy(tAiplmText2imgDto, TAiplmText2img.class);
		boolean isSuccess = tAiplmText2imgService.addTAiplmText2img(tAiplmText2img);
		return Response.status(isSuccess);
	}

	/**
	 * 修改 
	 */
	@PutMapping("/{id}")
	@ApiOperation(value = "修改", notes = "传入tAiplmText2img")
	@SaCheckPermission("t_aiplm_text2img:modify")
	public Response update(@PathVariable String id, @RequestBody SaveTAiplmText2imgFormDataDto formDto) {
		TAiplmText2imgDto tAiplmText2imgDto = formDto.getTAiplmText2imgDto();
		TAiplmText2img tAiplmText2img = BeanUtil.copy(tAiplmText2imgDto, TAiplmText2img.class);
		return Response.status(tAiplmText2imgService.updateTAiplmText2img(id, tAiplmText2img));
	}



	/**
	 * 删除 
	 */
	@DeleteMapping("/{ids}")
	@ApiOperation(value = "删除", notes = "传入ids")
	@SaCheckPermission(value = {"t_aiplm_text2img:batchDelete", "t_aiplm_text2img:delete"}, mode = SaMode.OR)
	public Response remove(@ApiParam(value = "主键集合", required = true) @PathVariable String ids) {
		return Response.status(tAiplmText2imgService.delete(ids));
	}


}
